{extend name='../../admin/view/table'}

{block name="button"}

{/block}

{block name="content"}
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        {foreach ['index'=>'企业投诉'] as $k=>$v}{if isset($type) and $type eq $k}
        <li data-open="{:url('index')}?type={$k}" class="layui-this">{$v}</li>
        {else}
        <li data-open="{:url('index')}?type={$k}">{$v}</li>
        {/if}{/foreach}
    </ul>
    <div class="layui-tab-content">
        {include file='user/tousu/index_search'}
        <table id="TagsData" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
    </div>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        // 初始化表格组件
        $('#TagsData').layTable({
            even: true, height: 'full',
            sort: {field: 'id desc', type: 'desc'},
            cols: [[
                {field: 'id', title: 'ID', width: 80, align: 'center', sort: true},
                {field: 'qymc', title: '企业名称', minWidth: 100},
                {field: 'tsrxm', title: '投诉人姓名', minWidth: 80},
                {field: 'tsrdh', title: '投诉人电话', minWidth: 80},
                {field: 'danwei_name', title: '部门', minWidth: 100},
                {field: 'keshi_name', title: '科室', minWidth: 100},
                {field: 'tsnr', title: '投诉内容', minWidth: 150},
                {field: 'create_at', title: '投诉时间', align: 'center', minWidth: 170, sort: true},
                {
                    field: 'tsimg', title: '图片', align: 'center', minWidth: 100,  templet: function (d) {
                        if (!d.tsimg) return '';
                        let html = '';
                        d.tsimg.forEach(item=>{
                            html += `<div data-tips-image data-tips-hover class="headimg headimg-xs headimg-no margin-0" data-lazy-src="${item}"></div>
`
                        })
                        return html
                    }
                },
                {field: 'clzt', title: '处理状态', align: 'center', minWidth: 80,templet: function (d){
                        if (d.clzt==1){
                            return "<span class='layui-badge layui-bg-red'>" + '已处理' + "</span>" ;
                        }else if (d.clzt==2){
                            return "<span class='layui-badge layui-bg-green'>" + '未处理' + "</span>" ;
                        }
                    }},
                {field: 'cljg', title: '处理结果', minWidth: 150},
                {toolbar: '#TagsTpl', title: '处理', minWidth: 100, align: 'center', fixed: 'right'},
            ]]
        });

        // 数据状态切换操作
        layui.form.on('switch(StatusSwitch)', function (obj) {
            var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
            $.form.load("{:url('state')}", data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#NewsTable').trigger('reload');
                }); else {
                    $('#NewsTable').trigger('reload');
                }
                return false;
            }, false);
        });
    });

</script>

<script type="text/html" id="TagsTpl">
    <!--<div class="layui-form-item layui-inline">-->
    <!--    <button class="layui-btn" data-title="财务审核"-->
    <!--            data-modal="{:url('edit')}?id={{d.id}}"-->
    <!--            type="button">-->
    <!--        审核-->
    <!--    </button>-->
    <!--</div>-->

    {{# if(d.status === 1) { }}
    <div class="layui-form-item layui-inline">
        <button class="layui-btn" data-title="处理"
                data-modal="{:url('edit')}?id={{d.id}}"
                type="button">
            处理
        </button>
    </div>
    {{# } else { }}
    <div class="layui-form-item layui-inline">
        <span>已处理</span>
    </div>
    {{# } }}
</script>


<!-- 列表排序权重模板 -->
<script type="text/html" id="SortInputTpl">
    <input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}"
           data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}"
           class="layui-input text-center">
</script>

<!-- 数据状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
    <!--{if auth("state")}-->
    <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch"
           {{-d.status>0?'checked':''}}>
    <!--{else}-->
    {{-d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
    <!--{/if}-->
</script>

<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">

    <button class='layui-btn layui-btn-sm layui-btn-primary'
            data-modal='{:url("msjx.msjxJinzhan/index")}?zc_id={{d.id}}' data-title="添加进展" data-width="920px">添加进展
    </button>


    <!--{if auth("edit") and isset($type) and $type eq 'index'}-->
    <a class="layui-btn layui-btn-primary layui-btn-sm" data-open='{:url("edit")}?id={{d.id}}'>编 辑</a>
    <!--{/if}-->


    <!--    &lt;!&ndash;{if isset($type) and $type eq 'index'}&ndash;&gt;-->
    <!--    {{#  if(d.tj_status == 1){ }}-->
    <!--    <a class="layui-btn layui-btn-normal layui-btn-sm" data-open='{:url("shenhe")}?id={{d.id}}'>审核</a>-->
    <!--    {{#  } }}-->
    <!--    &lt;!&ndash;{/if}&ndash;&gt;-->

    <!--    &lt;!&ndash;{if isset($type) and $type eq 'index'}&ndash;&gt;-->
    <!--    {{#  if(d.tj_status == 2){ }}-->
    <!--    <a class="layui-btn layui-btn-danger layui-btn-sm" data-open='{:url("gongshi")}?id={{d.id}}'>公示</a>-->
    <!--    {{#  } }}-->
    <!--    &lt;!&ndash;{/if}&ndash;&gt;-->

    <!--    &lt;!&ndash;{if isset($type) and $type eq 'index'}&ndash;&gt;-->
    <!--    {{#  if(d.tj_status == 3){ }}-->
    <!--    <a class="layui-btn layui-btn-warm layui-btn-sm" data-open='{:url("luoshi")}?id={{d.id}}'>落实</a>-->
    <!--    {{#  } }}-->
    <!--    &lt;!&ndash;{/if}&ndash;&gt;-->


    <!--{if auth("remove") and isset($type) }-->
    <a class="layui-btn layui-btn-danger layui-btn-sm" data-action="{:url('remove')}" data-value="id#{{d.id}}"
       data-confirm="确定要删除吗?">删 除</a>
    <!--{/if}-->
</script>
{/block}